//
//  NSData+Plist.m
//  JQKit
//
//  Created by JQZ on 2018/1/9.
//  Copyright © 2018年 JQZ. All rights reserved.
//

#import "NSData+Plist.h"

@implementation NSData (Plist)

- (id)propertyListFromPlistDataWithError:(out NSError **)error
{
    NSPropertyListFormat format = NSPropertyListBinaryFormat_v1_0;
    id propertyList = [NSPropertyListSerialization propertyListWithData:self
                                                                options:NSPropertyListImmutable
                                                                 format:&format
                                                                  error:error];
    return propertyList;
}

+ (NSData *)dataWithPropertyList:(id)plist error:(out NSError **)error
{
    NSData *data = nil;
    if (plist) {
        data = [NSPropertyListSerialization dataWithPropertyList:plist
                                                          format:NSPropertyListBinaryFormat_v1_0
                                                         options:NSPropertyListImmutable
                                                           error:error];
    }
    return data;
}

@end
